const HtmlWebpackPlugin = require('html-webpack-plugin')
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin')

/** @type {import('webpack').Configuration} */
module.exports = {
    mode: 'development',
    entry: './src/main.js',
    devServer: {
        port: 8082
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './public/index.html'
        }),
        new ModuleFederationPlugin({
            name: 'product',
            filename: 'remoteEntry.js',
            exposes: {
                // 把./src/index.js 映射为./index
                './main': './src/main.js'
            },
            shared: ['faker']
        })
    ]
}